home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-06 | 1.2 KB | 51 lines | [TEXT/PJMM] |
- program Levenshtein_test;
-
- uses
- Levenshtein;
-
- procedure PrepareTextWindow;
- const
- MaxVSize = 300;
- MaxHSize = 500;
- var
- aRect: Rect;
- begin
- aRect := screenBits.bounds;
- InsetRect(aRect, 40, 40);
- with aRect do
- begin
- if bottom - top > MaxVSize then
- bottom := top + MaxVSize;
- if right - left > MaxHSize then
- right := left + MaxHSize;
- end;
- SetTextRect(aRect);
- ShowText;
- end;
-
- var
- matchCost, insertCost, deleteCost, substituteCost: Integer;
- aString, bString: Str255;
- distance, moves, i: Integer;
- opsH: LevOpsHdl;
-
- begin
- PrepareTextWindow;
- writeln('Enter costs for match, insert, delete, substitute:');
- readln(matchCost, insertCost, deleteCost, substituteCost);
- InitLevDist(matchCost, insertCost, deleteCost, substituteCost);
- opsH := LevOpsHdl(NewHandle(0));
- repeat
- writeln('Enter two strings');
- readln(aString);
- readln(bString);
- distance := LevDist(aString, bString, opsH, moves);
- writeln('Levenshtein distance = ', distance : 1);
- HLock(Handle(opsH));
- for i := 1 to moves do
- with opsH^^[i] do
- writeln(i : 1, ' (', iA : 1, ',', iB : 1, ') ', op);
- HUnlock(Handle(opsH));
- until (aString = '') and (bString = '');
-
- end.